package main

import (
	"fmt"
	"time"
)

func main() {
	now := time.Now()
	fmt.Println(now)
	fmt.Println(now.Year(), now.Month(), now.Day(), now.Hour(), now.Minute())

	d1, err := time.Parse("2006-01-02 15:04:05", "2021-07-17 12:12:12")
	fmt.Println(d1, err)
	fmt.Println(now.After(d1))
	fmt.Println(now.Before(d1))
	fmt.Println(now.Equal(d1))

	//时间戳转换
	fmt.Println(time.Unix(time.Now().Unix(), 0))

	//时长计算
	after1 := now.Add(time.Hour * 24)
	fmt.Println(after1)

	time.Sleep(10 * time.Second)
	//时间点相减
	after2 := now.Add(time.Minute * 24)
	fmt.Println(now.Sub(after2))
}
